package leetcodecompetition.S115;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: Siantar
 * @Date: 2023-10-14-22:33
 * @Description: 1.0
 */
public class T100095 {
    public List<Integer> lastVisitedIntegers(List<String> words) {
        List<Integer> list = new ArrayList<>();
        List<Integer> res = new ArrayList<>();
        int d = 0;
        for (String word : words) {
            if (word.equals("prev")) {
                int r = -1, n = list.size();
                if (n - d >= 0 && n - d < n) r = list.get(n - d);
                res.add(r);
                d++;
            } else {
                System.out.println(word);
                list.add(Integer.valueOf(word));
                d = 0;
            }
        }
        return res;
    }
}
